package com.liu.demo4.dao;

import com.liu.demo4.entity.Student;
import com.liu.demo4.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserDao {
    @Results(id = "userMap",value = {
            @Result(property = "name",column = "username"),
            @Result(property = "password",column = "password")
    })
    @Select("select * from user where username = #{username} and password = #{password}")
    User getUserByName(@Param("username") String name,String password);

//    @Insert("insert into user(username,password) values (#{username},#{password})")
//    int creatUser(User user);
    @Update("update user set password = #{password} where username = #{username}")
    int updateUserPassword(@Param("username") String username, @Param("password") String password);

    @Delete("delete from user where username = #{username}")
    int deleteUser(@Param("username") String username);

    @Select("select count(1) from user where username = #{name}")
    int findUserByName(User user);

    @Insert("insert into user(username,password) values (#{name},#{password})")
    int creatUser(User user);

}